home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Developer Utilities / Installer 4.0.3 SDK / Script Examples / Font Compression Example / fontCompress.r < prev    next >
Encoding:
Text File  |  1994-11-15  |  19.7 KB  |  571 lines  |  [TEXT/MPS ]

  1. //
  2. //    fontCompress.r
  3. //
  4. //        This example demonstrates use of InstaCompOne for Font compression 
  5. //        with the Apple Installer 4.x. Fonts are installed through compression, 
  6. //        and through font splitting and compression. For reference, an example
  7. //        of installing a font without compression or splitting is included.
  8. //
  9. //    How To Build the Script:
  10. //    
  11. //        To build installer script access "Build…" item within "Build" menu
  12. //        and enter the scriptName "fontCompress". To build the installer
  13. //        debugger version of the installer script enter the scriptname
  14. //        with the addition ".debug" ( "fontCompress.debug" ).
  15. //
  16. //        There must be a copy of the file "InstaCompOneSCExt.rsrc"
  17. //        that has been renamed to "fontCompress.scx" included in this
  18. //        folder as well. This file will automatically be copied and
  19. //        renamed ( from the InstaCompOne folder in the SDK ) when the
  20. //        makefile for this example is run.
  21. //
  22. //    What this example does :
  23. //
  24. //      This example demonstrates use of InstaCompOne archives, 
  25. //        the FileAndRsrcSplitterTool, and the InstaCompOneTool compression 
  26. //        utility to install fonts. This example uses the Installer 3.x style of 
  27. //        creating Custom Install options for sake of simplicity and is not 
  28. //        intended as an example of how to create Installer 4.0 Easy or 
  29. //        Custom Install options. 
  30. //
  31. //        This example shows how to compress a font, and how to split and
  32. //        compress a font; but is does not demonstrate splitting a font
  33. //        without compression.
  34. //
  35. //
  36. //    ================= fonts and the Apple 4.0 Installer ====================
  37. //
  38. //      The Apple Installer 4.0 handles font installation automatically
  39. //      for different versions of the Macintosh operating system.
  40. //      Pre-7.0, 7.0, and post-7.0 systems are all supported with
  41. //      identical installer source script code.
  42. //
  43. //      To utilize this automated installation of fonts, simply specify
  44. //      the "special-fonts:" file path in the target spec ( 'intf' ) 
  45. //        for the font to be installed.
  46. //   
  47. //  ================== preparing split or compressed files =================
  48. //
  49. //
  50. //        case #1 : Font compressed directly into a single archive :
  51. //
  52. //             1) Compress each font resource item ( except 'FOND')
  53. //                within the source font file into a 'part'
  54. //                 resource with a unique rsrc ID within an archive. This
  55. //                 must be done for each ID of each resource type
  56. //                 except 'FOND'.
  57. //             Example:
  58. //                InstaCompOneTool {FontFileName} -k sfnt=9217 -a part=128 -o {FontArchiveName}
  59. //
  60. //             NOTE: It's best to specify 'part' and a unique rsrc ID for each
  61. //                 compressed resource archive created within the source file.
  62. //                 ( This does not include resources of type 'FOND')
  63. //
  64. //             2) Copy ( without compression ) the 'FOND' resource
  65. //                 from the source font file into a 'iFND' resource within
  66. //                 the same archive containing the 'part' resources that
  67. //                 were created in step 1).
  68. //             Example - FONDEncoderTool {FontFileName} -o {FontArchiveName} 
  69. //
  70. //             NOTE: Be sure that the 'FOND' resource is given the
  71. //                 resource type of 'iFND' within the archive, and that
  72. //                 it's original rsrc ID is retained. The example line
  73. //                 above will copy the 'FOND' resource to the archive,
  74. //                 giving it a new resource type of 'iFND' and retaining
  75. //                 the original resource ID. The 'FOND' resources should 
  76. //                NEVER be compressed when using InstaCompOne compression.
  77. //
  78. //     EXAMPLE SUMMARY ( case #1 ): This is the simplest case of using InstaCompOne
  79. //  compression for font installation. One font is compressed into a single
  80. //  archive. You may wish to compress many fonts into one InstaCompOne
  81. //  archive. To do this, just be sure and assign each compressed resource
  82. //  the resource type 'part' and a unique ID for each compressed item and to
  83. //    use the FONDEncoderTool for each font contained in the archive.
  84. //  ============================================================================
  85. //
  86. //        case #2 : Font split, then compressed into seperate archives :
  87. //
  88. //        
  89. //          1) Choose a resource item ( not an entire resource type )
  90. //              that you want to split within the source font file.
  91. //              This resource item should not be of type 'FOND'.
  92. //           2) Split the resource into two or more resources
  93. //              within a temporary file.
  94. //          Example - FileAndRsrcSplitterTool {SplitFontFileName} -k sfnt=17127 
  95. //                ( cont. )     -a sfnt=200 -s 30000 -o {SplitFontTempName}
  96. //
  97. //          NOTE: When splitting the resource item into two or more
  98. //              resource items in a temporary file, be sure to retain
  99. //              the original resource type for the resource items being
  100. //              created in the temporary resource file. This will ensure that 
  101. //                 when the split resources are compressed the InstaCompOne atom extender
  102. //                will be able to identify the original resource type of the 
  103. //                split resources.
  104. //
  105. //          NOTE: Be sure to specify a unique base ID for the split
  106. //                resource items created within the temporary file. This
  107. //                will ensure that each new resource item can be described
  108. //                when using the InstaCompOne MPW tool to compress the
  109. //                individual split resource pieces.
  110. //
  111. //            3) Compress the two resources within the temporary file
  112. //              ( created in step 2) ) into two seperate InstaCompOne archives.
  113. //            Example: InstaCompOneTool {SplitFontTempName} -k sfnt=200 -a part=200 -o {SplitFontArchive1} 
  114. //          More:     InstaCompOneTool {SplitFontTempName} -k sfnt=201 -a part=201 -o {SplitFontArchive2}
  115. //
  116. //          NOTE: Be sure to specify a target resource type of 'part'
  117. //              and a unique ID for each compressed resource within the
  118. //              InstaCompOne archive. This will ensure that the InstaCompOne
  119. //                 atom extender will be able to find and decompress each font
  120. //               resource successfully. The InstaCompOne atom extender
  121. //              ( decompressor ) expects resources of type 'part'.
  122. //
  123. //          NOTE: It is not absolutely necessary to compress the two
  124. //              split pieces into two seperate archives, but there seems
  125. //              little use in splitting a resource and then putting both
  126. //              of the split pieces into the same archive.
  127. //
  128. //            4) Compress each remaining resources ( except 'FOND' )
  129. //                within the source font file into a 'part'
  130. //              resource item within an InstaCompOne archive.
  131. //          Example:
  132. //                InstaCompOneTool {SplitFontFileName} -k NFNT=17774 -a part=300 -o {SplitFontArchive1} 
  133. //
  134. //             NOTE: It's best to specify 'part' and a unique rsrc ID for each
  135. //                 compressed resource archive created within the source file.
  136. //                 ( This does not include resources of type 'FOND')
  137. //
  138. //             5) Copy ( without compression ) the 'FOND' resource
  139. //                 from the source font file into a 'iFND' resource within
  140. //                 the same archive containing the 'part' resources that
  141. //                 were created in step 1).
  142. //             Example - FONDEncoderTool {FontFileName} -o {FontArchiveName} 
  143. //
  144. //             NOTE: The example line above will copy the 'FOND' resource 
  145. //                to the archive, giving the 'FOND' resource a new resource 
  146. //                type of 'iFND' and retaining the original resource ID. 
  147. //                The 'FOND' resources should NEVER be compressed when using 
  148. //                InstaCompOne compression.
  149. //
  150. //     ============================================================================
  151. //
  152. //     NOTE: When using InstaCompOne compression, simply enter 241
  153. //     as the value for the atom extender ( 'inex' ) in the next to last field
  154. //     of the atom ( 'infa', 'inff', 'inra' ) for the file/font/rsrc to be
  155. //     decompressed. There is no need to declare an 'inex' resource within the
  156. //     installer script source. An 'inex' resource definition is contained in
  157. //     the InstaCompOne resource file that is included at the top of this file.
  158. //
  159. //    If not using compression, enter a value of 0 ( zero ) for the
  160. //    atom extender field in the atom ( 'infa', 'inra', 'inff' ).
  161. //
  162. //
  163. //
  164. //      mark young • 08/17/94
  165. //
  166. //        Copyright 1993-1994, Apple Computer, Inc., All Rights Reserved
  167. //
  168.  
  169. #include "InstallerTypes.r"
  170.  
  171. // Include the InstaCompOne atom extender stuff
  172. // making sure not to add their version resource
  173. // to our installer script. Also, since this include
  174. // is a resource include instead of a #include, it is
  175. // not actually a pre-processor thing, and won't be effected
  176. // by a -i option within the rez line in the makefile. 
  177. include ":::InstaCompOne 1.0:InstaCompOneAtomExt.rsrc" NOT 'vers';
  178.  
  179.  
  180. // • packages
  181.  
  182. // package that demonstrates installation of a font without compression
  183. resource 'inpk' (400) {
  184.     format0 {
  185.         showsOnCustom,
  186.         removable,
  187.         dontForceRestart,
  188.         0,
  189.         0,
  190.         "Times font - no compression.",
  191.         {    
  192.         'inff', 4000;
  193.         },
  194.     }
  195. };
  196.  
  197. // package that demonstrates compressing a font into an archive
  198. resource 'inpk' (500) {
  199.     format0 {
  200.         showsOnCustom,
  201.         removable,
  202.         dontForceRestart,
  203.         0,
  204.         0,
  205.         "Chicago font - compression.",
  206.         {    
  207.         'inff', 5000;
  208.         },
  209.     }
  210. };
  211.  
  212. // package that demonstrates splitting and compressing a font into an archive
  213. resource 'inpk' (600) {
  214.     format0 {
  215.         showsOnCustom,
  216.         removable,
  217.         dontForceRestart,
  218.         0,
  219.         0,
  220.         "Monaco font - splitting and compression.",
  221.         {    
  222.         'inff', 6000;
  223.         },
  224.     }
  225. };
  226.  
  227.  
  228. // • font atoms
  229.  
  230. // this first font example does not use compression, but is included for reference
  231.  
  232. // font non-compressed example
  233. // font => single target file
  234. resource 'inff' (4000) {
  235.     format1 {
  236.         deleteWhenRemoving,                //  Delete on deinstall
  237.         deleteWhenInstalling,            //  Remove preexisting
  238.         copy,                            //  Copy on Install
  239.         noTgtRequired,                    //    Create new file if necessary
  240.         updateExisting,                    //    Always replace items in target file
  241.         copyIfNewOrUpdate,                //    Always copy file
  242.         dontIgnoreProtection,            //  Respect file locking
  243.         srcNeedNotExist,                //  Create a new file if necessary
  244.         
  245.         byName,                            //     Reference resources by name
  246.                                         //    'byID' allowed only w/'explicitFamilyMembers'
  247.                                         
  248.         nameNeedNotMatch,                //    Ignored when 'byName' is specified
  249.                 
  250.         14001,                // TARGET - file spec ( 'intf' )
  251.         14000,                // SOURCE - file spec ( 'infs' )
  252.         
  253.         0,                     // TARGET - 'FOND' attributes ( set by scriptcheck )
  254.         0,                    // TARGET - Font Family size  ( set by scriptcheck )
  255.         
  256.         
  257.         20,                    // 'FOND' ID
  258.                             
  259.                             
  260.         entireFamily{},        // Copy option ( copy entire font and all attributes )
  261.         0,                    // Atom extender ID ( none used for this atom )
  262.         "",                    // Font atom description
  263.         "Times"                // FOND family name
  264.     }
  265. };
  266.  
  267.  
  268. // font compression example
  269. // font => archive => single target file
  270. resource 'inff' (5000) {
  271.     format2 {
  272.         deleteWhenRemoving,                //  Delete on deinstall
  273.         deleteWhenInstalling,            //  Remove preexisting
  274.         copy,                            //  Copy on Install
  275.         encodedFONDRsrc,                //  • use the FONDEncoder tool to tweak FOND resource
  276.         noTgtRequired,                    //    Create new file if necessary
  277.         updateExisting,                    //    Always replace items in target file
  278.         copyIfNewOrUpdate,                //    Always copy file
  279.         dontIgnoreProtection,            //  Respect file locking
  280.         srcNeedExist,                    //  Require a source file
  281.         
  282.         byID,                            //     Reference resources by ID
  283.                                         //    'byID' allowed only w/'explicitFamilyMembers'
  284.                                         
  285.         nameNeedNotMatch,                //    Ignored when 'byName' is specified
  286.                 
  287.         15001,                            // TARGET - file spec ( 'intf' )
  288.         15000,                            // SOURCE - file spec ( 'infs' )
  289.         
  290.         0,                                 // TARGET - 'FOND' attributes ( set by scriptcheck )
  291.         0,                                // TARGET - Font Family size ( set by scriptcheck )
  292.         
  293.         0,                                // 'FOND' ID
  294.                             
  295.                             
  296.         explicitFamilyMembers{    // Copy option ( copy only specified items )
  297.             {
  298.             
  299.                 // • 'sfnt' portion
  300.                 
  301.                 0,                     // Target - Point Size
  302.                 
  303.                 noExtendedStyle,     // Target - Style attributes
  304.                 noCondensedStyle, 
  305.                 noShadowStyle, 
  306.                 noOutlineStyle, 
  307.                 noUnderlineStyle, 
  308.                 noItalicStyle, 
  309.                 noBoldStyle,     
  310.  
  311.                 'sfnt',                // Target - Resource Type
  312.                 resPurgeable,        // Target - Resource Attributes
  313.             
  314.                 {
  315.                     15000,        // Source - Resource File Spec ID
  316.                     'part',     // Source - Resource Type
  317.                     128,        // Source - Resource ID
  318.                     0,            // Resource Size ( filled in by ScriptCheck )
  319.                     "Chicago",    // Resource Name
  320.                 },
  321.             
  322.             
  323.                 // • 'NFNT' portion
  324.                 
  325.                 12,                 // Target - Point Size
  326.                 
  327.                 noExtendedStyle,     // Target - Style attributes
  328.                 noCondensedStyle, 
  329.                 noShadowStyle, 
  330.                 noOutlineStyle, 
  331.                 noUnderlineStyle, 
  332.                 noItalicStyle, 
  333.                 noBoldStyle,     
  334.  
  335.                 'NFNT',                // Target - Resource Type
  336.                 0,                    // Target - Resource Attributes
  337.             
  338.                 {
  339.                     15000,        // Source - Resource File Spec ID
  340.                     'part',     // Source - Resource Type
  341.                     129,        // Source - Resource ID
  342.                     0,            // Resource Size ( filled in by ScriptCheck )
  343.                     "",            // Resource Name ( 'NFNT's don't use named resource )
  344.                 },
  345.             
  346.             }
  347.             
  348.         },    
  349.         241,                            //  Atom extender ID for InstaCompOne
  350.         "",                                //  Font atom description
  351.         "Chicago"                        //  FOND family name
  352.     }
  353. };
  354.  
  355.  
  356. // font compression example
  357. // font => split => archive(s) => single target file
  358. resource 'inff' (6000) {
  359.     format2 {
  360.         deleteWhenRemoving,                //  Delete on deinstall
  361.         deleteWhenInstalling,            //  Remove preexisting
  362.         copy,                            //  Copy on Install
  363.         encodedFONDRsrc,                //  • use the FONDEncoder tool to tweak FOND resource
  364.         noTgtRequired,                    //    Create new file if necessary
  365.         updateExisting,                    //    Always replace items in target file
  366.         copyIfNewOrUpdate,                //    Always copy file
  367.         dontIgnoreProtection,            //  Respect file locking
  368.         srcNeedExist,                    //  Require a source file
  369.         
  370.         byID,                            //     Reference resources by ID
  371.                                         //    'byID' allowed only w/'explicitFamilyMembers'
  372.                                         
  373.         nameNeedNotMatch,                //    Ignored when 'byName' is specified
  374.                 
  375.         16001,                            //  TARGET - file spec ( 'intf' )
  376.         16000,                            //  SOURCE - file spec ( 'infs' )
  377.         
  378.         0,                                 //  TARGET - 'FOND' attributes ( set by scriptcheck )
  379.         0,                                //  TARGET - Font Family size  ( set by scriptcheck )
  380.         
  381.         4,                                // 'FOND' ID
  382.                             
  383.                             
  384.         explicitFamilyMembers{    // Copy option ( copy only specified items )
  385.             {
  386.             // • NOTE ON SPLITTING RESOURCES:
  387.             // •   you may split as many resources from a source file as you wish, 
  388.             // •   but the most straight-forward approach to splitting resources
  389.             // •   is to place as many entire resources as will fit in one install
  390.             // •   disk and to split only those resources that will fill up the
  391.             // •   remaining portion of the install disk )
  392.                 
  393.             // • 'sfnt' portion will be split ( two source specs, one shared target spec )
  394.                 
  395.                 0,                     // Point Size
  396.                 
  397.                 noExtendedStyle,     // Style attributes
  398.                 noCondensedStyle, 
  399.                 noShadowStyle, 
  400.                 noOutlineStyle, 
  401.                 noUnderlineStyle, 
  402.                 noItalicStyle, 
  403.                 noBoldStyle,     
  404.                 
  405.                 'sfnt',                // Target - Resource Type
  406.                 0,                    // Target - Resource Attributes ( set by scriptcheck )
  407.             
  408.                 {
  409.                     16000,        // Split Resource - Source - file spec ( 'infs' )
  410.                     'part',     // Split Resource - Source -  Resource Type
  411.                     200,        // Split Resource - Source -  Resource ID
  412.                     0,            // Split Resource - Resource Size ( set by scriptcheck )
  413.                     "",            // Split Resource - Resource Name
  414.  
  415.  
  416.                     17000,        // Split Resource - Source - file spec ( 'infs' )
  417.                     'part',     // Split Resource - Source -  Resource Type
  418.                     201,        // Split Resource - Source -  Resource ID
  419.                     0,            // Split Resource - Resource Size ( set by scriptcheck )
  420.                     "",            // Split Resource - Resource Name
  421.                 },
  422.             
  423.             
  424.                 // • 'NFNT' portion will NOT be split, use standard compression
  425.                                 
  426.                 9,                     // Target - Point Size
  427.                 
  428.                 noExtendedStyle,     // Target - Style attributes
  429.                 noCondensedStyle, 
  430.                 noShadowStyle, 
  431.                 noOutlineStyle, 
  432.                 noUnderlineStyle, 
  433.                 noItalicStyle, 
  434.                 noBoldStyle,     
  435.  
  436.                 'NFNT',                // Target - Resource Type
  437.                 0,                    // Target - Resource Attributes ( set by scriptcheck )
  438.             
  439.                 {
  440.                     16000,        // Source - file spec ( 'infs' )
  441.                     'part',     // Source - Resource Type
  442.                     300,        // Source - Resource ID
  443.                     0,            // Resource Size ( set by scriptcheck )
  444.                     "",            // Resource Name
  445.                 },
  446.             
  447.                 // • 'NFNT' portion will NOT be split, use standard compression
  448.                 
  449.                 12,                 // Target - Point Size
  450.                 
  451.                 noExtendedStyle,     // Target - Style attributes
  452.                 noCondensedStyle, 
  453.                 noShadowStyle, 
  454.                 noOutlineStyle, 
  455.                 noUnderlineStyle, 
  456.                 noItalicStyle, 
  457.                 noBoldStyle,     
  458.  
  459.                 'NFNT',                // Target - Resource Type
  460.                 0,                    // Target - Resource Attributes
  461.             
  462.                 {
  463.                     16000,        // Source - file spec ( 'infs' )
  464.                     'part',     // Source - Resource Type
  465.                     301,        // Source - Resource ID
  466.                     0,            // Source Resource Size ( set by scriptcheck )
  467.                     "",            // Source Resource Name
  468.                 },
  469.             
  470.             }
  471.             
  472.         },    
  473.         241,                            // Atom extender ID for InstaCompOne
  474.         "",                                // Font atom description
  475.         "Monaco"                        // FOND family name
  476.     }
  477. };
  478.  
  479.  
  480. // • font specs
  481.  
  482. // source file spec for font installation w/o compression
  483. resource 'infs' (14000) {
  484.     'FFIL',                        // TYPE 
  485.     'DMOV',                        // CREATOR 
  486.     0x0,                        // creation DATE for source file
  487.     noSearchForFile,            // IGNORED in Installer 4.0.x
  488.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  489.     "Disk 1:Times"                // PATH to source file        
  490. };
  491.  
  492. // target file spec for font installation w/o compression
  493. resource 'intf' (14001) {
  494.     format1 {
  495.         noSearchForFile,        // use default search path
  496.         TypeCrMustMatch,        // ??
  497.         'FFIL',                    // TYPE for file search
  498.         'DMOV',                    // CREATOR for file search
  499.         0,                        // Finder flags for target ( specify 0 for ScriptCheck to fill in )
  500.         1,                        // Creation date for target ( specify 1 for ScriptCheck to fill in )
  501.         1,                        // Modification date for target ( specify 1 for ScriptCheck to fill in )
  502.         0,                        // 'insp' resource ID ( file search proc )
  503.         "special-font:Times"    // path to target file
  504.     }
  505. };
  506.  
  507.  
  508. // source file spec for font installation with compression
  509. resource 'infs' (15000) {
  510.     'ircp',                        // TYPE 
  511.     'kakc',                        // CREATOR 
  512.     0x0,                        // creation DATE for source file
  513.     noSearchForFile,            // IGNORED in Installer 4.0.x
  514.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  515.     "Disk 1:fontTome"            // PATH to source file        
  516. };
  517.  
  518. // target file spec for font installation with compression
  519. resource 'intf' (15001) {
  520.     format1 {
  521.         noSearchForFile,        // use default search path
  522.         TypeCrMustMatch,        // ??
  523.         'FFIL',                    // TYPE for file search
  524.         'DMOV',                    // CREATOR for file search
  525.         0,                        // Finder flags for target ( specify 0 for ScriptCheck to fill in )
  526.         1,                        // Creation date for target ( specify 1 for ScriptCheck to fill in )
  527.         1,                        // Modification date for target ( specify 1 for ScriptCheck to fill in )
  528.         0,                        // 'insp' resource ID ( file search proc )
  529.         "special-font:Chicago"    // path to target file
  530.     }
  531. };
  532.  
  533.  
  534.  
  535. // source file spec for font installation with split compression
  536. resource 'infs' (16000) {
  537.     'ircp',                        // TYPE 
  538.     'kakc',                        // CREATOR 
  539.     0x0,                        // creation DATE for source file
  540.     noSearchForFile,            // IGNORED in Installer 4.0.x
  541.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  542.     "Disk 1:splitFontTome1"        // PATH to source file        
  543. };
  544.  
  545. // source file spec for font installation with split compression
  546. resource 'infs' (17000) {
  547.     'ircp',                        // TYPE 
  548.     'kakc',                        // CREATOR 
  549.     0x0,                        // creation DATE for source file
  550.     noSearchForFile,            // IGNORED in Installer 4.0.x
  551.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  552.     "Disk 2:splitFontTome2"        // PATH to source file        
  553. };
  554.  
  555. // target file spec for font installation w/split compression
  556. resource 'intf' (16001) {
  557.     format1 {
  558.         noSearchForFile,        // use default search path
  559.         TypeCrMustMatch,        // ??
  560.         'FFIL',                    // TYPE for file search
  561.         'DMOV',                    // CREATOR for file search
  562.         0,                        // Finder flags for target ( specify 0 for ScriptCheck to fill in )
  563.         1,                        // Creation date for target ( specify 1 for ScriptCheck to fill in )
  564.         1,                        // Modification date for target ( specify 1 for ScriptCheck to fill in )
  565.         0,                        // 'insp' resource ID ( file search proc )
  566.         "special-font:Monaco"    // path to target file
  567.     }
  568. };
  569.  
  570.  
  571.